package top.wanzc.java.basic.demo;

public class StringDemo {
	
	public static void main(String[] args) {
		String a = "xiaocao2";
		final String b = "xiaocao";
		String d = "xiaocao";
		String c = b + 2;   // 常量折叠，编译时直接合并成xiaocao2
		String e = d + 2;   // 等同于new StringBuilder(a).append(b).toString(); 
		System.out.println(a == c);
		System.out.println(a == e);
		// javap -c xiaocao/java/basic/demo/StringDemo.class
		// 借助javap -c来查看具体的字节码
		
		// java9 String的底层存储换使用byte[]来替换char[]
		String s = "𩑃";
		System.out.println(s.length());
		System.out.println(s.codePointCount(0, s.length()));
	}

}
